🎖️GitЯра🎖️
.github/workflows/pr-closed-cleanup.yml bfb66eb988f8259e66ab4adb03dbffb900280d3f (bfb66eb9) Text, 1.70 KB
Tff7b72nameTb4b4b4: Ta5d6ffPRTa5d6ff Ta5d6ffClosedTa5d6ff Ta5d6ffCleanup
T8b949e# When a PR is closed (merged or abandoned) its in-flight CI runs keep burning
T8b949e# runner slots to completion: per-PR concurrency groups only cancel on a NEW
T8b949e# push, and nothing pushes to a closed PR. Reap queued/in-progress
T8b949e# pull_request-event runs for the closed PR's head SHA (pull-request.yml,
T8b949e# verify-flatpak.yml, ...). Runs for older SHAs were already cancelled by the
T8b949e# per-PR concurrency group when that SHA was superseded.
T8b949e#
T8b949e# pull_request_target is required: the plain pull_request event gets a
T8b949e# read-only GITHUB_TOKEN for fork PRs, which cannot cancel runs. Per the
T8b949e# pull_request_target warnings, this workflow must never check out or execute
T8b949e# PR code — it only calls the Actions API.
Tff7b72onTb4b4b4:
Tff7b72pull_request_targetTb4b4b4:
Tff7b72typesTb4b4b4: Tb4b4b4[Te6edf3closedTb4b4b4]
Tff7b72permissionsTb4b4b4:
Tff7b72actionsTb4b4b4: Ta5d6ffwrite
Tff7b72jobsTb4b4b4:
Tff7b72cancel-pr-runsTb4b4b4:
Tff7b72ifTb4b4b4: Ta5d6ffgithub.repositoryTa5d6ff Ta5d6ff==Ta5d6ff Ta5d6ff'meshtastic/Meshtastic-Android'
Tff7b72runs-onTb4b4b4: Ta5d6ffubuntu-24.04-arm
Tff7b72timeout-minutesTb4b4b4: Ta5d6ff5
Tff7b72stepsTb4b4b4:
Tb4b4b4- Tff7b72nameTb4b4b4: Ta5d6ffCancelTa5d6ff Ta5d6ffin-flightTa5d6ff Ta5d6ffCITa5d6ff Ta5d6ffrunsTa5d6ff Ta5d6ffforTa5d6ff Ta5d6fftheTa5d6ff Ta5d6ffclosedTa5d6ff Ta5d6ffPR
Tff7b72envTb4b4b4:
Tff7b72GH_TOKENTb4b4b4: Ta5d6ff${{Ta5d6ff Ta5d6ffgithub.tokenTa5d6ff Ta5d6ff}}
Tff7b72HEAD_SHATb4b4b4: Ta5d6ff${{Ta5d6ff Ta5d6ffgithub.event.pull_request.head.shaTa5d6ff Ta5d6ff}}
Tff7b72runTb4b4b4: Tb4b4b4|
Tff7b72set -euo pipefail
Tff7b72ids_file="$(mktemp)"
Tff7b72trap 'rm -f "$ids_file"' EXIT
Tff7b72for status in queued in_progress; do
Tff7b72gh api --paginate "repos/${{ github.repository }}/actions/runs?event=pull_request&status=${status}&head_sha=${HEAD_SHA}&per_page=100" \
Tff7b72--jq '.workflow_runs[].id'
Tff7b72done >"$ids_file"
Tff7b72sort -u "$ids_file" | while read -r run_id; do
Tff7b72echo "Cancelling run $run_id"
Tff7b72gh run cancel "$run_id" --repo "${{ github.repository }}" || true
Tff7b72done
Served by rngit 1.5.2 - Generated in 0.07s